//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef ADSL_STATTAB_H_
#define ADSL_STATTAB_H_

#include "def.h"
#include "logctrl.h"

typedef wxString (*OnStatus)(unsigned int nVal, bool& bLog );

class CADSLTab: public wxPanel, public IGUIBind, public IGUISupport, public IGUIXMLExecutor, public ILoggable, public ITabedPageUI
{
public:
								CADSLTab(class wxWindow* pParent);
	virtual						~CADSLTab();
	
	//IGUIBind
	virtual void				OnResponse(const COMMANDRESPONSE& resp);
	virtual void				Reset();

	//IGUISupport
	virtual bool				CanSave()	{ return  !m_data.empty(); }
	virtual wxString			Save();
	virtual bool				CanShowAdvanced();
	virtual void				ShowAdvanced(bool bShow/*=true*/);
	virtual bool				IsAdvancedShown();

	//IGUIXMLExecutor
	virtual void				ExecuteXML( const std::string& strXML );
	virtual void				SaveExecuteXML( const std::string& strXML );
	virtual std::string			LoadExecuteXML();

	virtual wxString			GetLog();

	virtual cTabPageID			GetTabID()		{ return cTabIDADSL;	}
	virtual bool IsTimeSelectorSupported()		{ return true;			}
	virtual time_t GetTimeInterval()			{ return m_tInt;		}
	virtual void SetTimeInterval(size_t tInt);
	
protected:
	void						OnTimeRangeChanged(wxCommandEvent& ev);
	void						OnTimeCRCRangeChanged(wxCommandEvent& ev);
	DECLARE_EVENT_TABLE()

private:
	void						ProcessResponse();

	//void						ParseResponse(const COMMANDRESPONSE& resp);
	//void						AddVal(const wxString& strSection, const wxString& strName, unsigned int lVal);  

	void						ShowAnalyze();
	wxString					AddTableLine(class CMarkupSTL&	doc, const char* szAttrib,const wxString& strParamName, const wxString& strParamMis, OnStatus st, int& nCount);
	wxString					AddTableLineTxt(class CMarkupSTL&	doc, const char* szAttrib,const wxString& strParamName, const wxString& strParamMis, OnStatus st, int& nCount);
	wxString					AddTableLine(unsigned long lVal, const wxString& strParamName, const wxString& strParamMis, OnStatus st, int& nCount);
	wxString					AddTableLine(const wxString& strTxt, const wxString& strParamName, const wxString& strParamMis, OnStatus st, int& nCount);

	wxString					AddLogLineTxt(class CMarkupSTL&	doc, const char* szAttrib,const wxString& strParamName, const wxString& strParamMis);
	wxString					AddLogLine(const wxString& strTxt, const wxString& strParamName);
	wxString					AddLogLine(class CMarkupSTL&	doc, const char* szAttrib,const wxString& strParamName, const wxString& strParamMis);


	bool						IsADSLBuiltIN();
	bool						IsADSLineConnected();

private:

	class CLevelGraph*			m_pErrorGraph;
	class CLevelGraph*			m_pLineSNR;

	class CLineGraph*			m_pBitsPerTone;
	class wxHtmlWindow*			m_pAnylizeWindow;

	RTSTRING					m_data;


	RTSTRING					m_strXML;

	class CXMLGUIPanel*			m_pAdvanced;

	time_t						m_tInt;
};

#endif /*ADSL_STATTAB_H_*/
